package com.hpjpw.ido.service.impl;

import java.util.List;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hpjpw.ido.mapper.TeacherMapper;
import com.hpjpw.ido.domain.Teacher;
import com.hpjpw.ido.service.ITeacherService;

/**
 * 老师Service业务层处理
 * 
 * @author hpj
 * @date 2021-01-02
 */
@Service
public class TeacherServiceImpl implements ITeacherService
{
    @Autowired
    private TeacherMapper teacherMapper;

    /**
     * 查询老师
     * 
     * @param id 老师ID
     * @return 老师
     */
    @Override
    public Teacher selectTeacherById(Long id)
    {
        return teacherMapper.selectTeacherById(id);
    }

    /**
     * 通过用户ID查询老师
     *
     * @param userId 用户ID
     * @return 老师对象信息
     */
    @Override
    public Teacher selectTeacherByUserId(Long userId) {
        return teacherMapper.selectTeacherByUserId(userId);
    }

    /**
     * 通过地区ID查询老师列表
     *
     * @param areaId 地区ID
     * @return 老师集合
     */
    @Override
    public List<Teacher> selectTeacherByAreaId(Long areaId) {
        return teacherMapper.selectTeacherByAreaId(areaId);
    }

    /**
     * 查询老师列表
     * 
     * @param teacher 老师
     * @return 老师
     */
    @Override
    public List<Teacher> selectTeacherList(Teacher teacher)
    {
        return teacherMapper.selectTeacherList(teacher);
    }

    /**
     * 通过职工号查询老师
     *
     * @param number 职工号
     * @return 老师对象信息
     */
    @Override
    public Teacher selectTeacherByNumber(String number) {
        return teacherMapper.selectTeacherByNumber(number);
    }

    /**
     * 校验职工号是否唯一
     *
     * @param teacher 老师信息
     * @return 结果
     */
    @Override
    public String checkNumberUnique(Teacher teacher) {
        Long Id = StringUtils.isNull(teacher.getId()) ? -1L : teacher.getId();
        Teacher info = teacherMapper.checkNumberUnique(teacher.getNumber());
        if (StringUtils.isNotNull(info) && info.getId().longValue() != Id.longValue())
        {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }

    /**
     * 新增老师
     * 
     * @param teacher 老师
     * @return 结果
     */
    @Override
    public int insertTeacher(Teacher teacher)
    {
        return teacherMapper.insertTeacher(teacher);
    }

    /**
     * 修改老师
     * 
     * @param teacher 老师
     * @return 结果
     */
    @Override
    public int updateTeacher(Teacher teacher)
    {
        return teacherMapper.updateTeacher(teacher);
    }

    /**
     * 批量删除老师
     * 
     * @param ids 需要删除的老师ID
     * @return 结果
     */
    @Override
    public int deleteTeacherByIds(Long[] ids)
    {
        return teacherMapper.deleteTeacherByIds(ids);
    }

    /**
     * 删除老师信息
     * 
     * @param id 老师ID
     * @return 结果
     */
    @Override
    public int deleteTeacherById(Long id)
    {
        return teacherMapper.deleteTeacherById(id);
    }
}
